//
//  ZLAlertView.swift
//  ZLAlert
//
//  Created by lxhd on 2025/4/15.
//

import Foundation

/// 标题
extension ZLAlert {
    /// 添加自定义视图
    /// - Parameter view: 视图
    /// - Returns: ZLAlert
    @discardableResult
    public func addView(_ view: UIView, _ config: ZLAlertItemConfig = ZLAlertConfig.shared.viewConfig) -> ZLAlert {
        let lastView = self.mainView.subviews.last
        self.mainView.addSubview(view)
        view.snp.makeConstraints { make in
            make.left.equalTo(self.mainView).offset(config.insets.left)
            make.right.equalTo(self.mainView).offset(-config.insets.right)
            if (lastView == nil) {
                make.top.equalTo(self.mainView).offset(config.insets.top)
            } else {
                make.top.equalTo(lastView!.snp.bottom).offset(config.insets.top)
            }
        }
        return self.layoutMainView(0)
    }
}
